﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 类和对象_重载方法
{
    class Program
    {
        static void Main(string[] args)
        {
            /* MyClass myClass = new MyClass(4, 5);
             Console.WriteLine(myClass.b );

             MyClass my = new MyClass();
             my.a = 3;
             my.b = 5;
             Console.WriteLine(my.a);*/


            Class1 class1 = new Class1();
            Class1 class2 = new Class1(3, 5);
        }
    }

    class MyClass
    {
        public int a;
        public int b;

        //默认方法
        public MyClass()
        {

        }

        //构造函数,方法明与类名一样,不需要写返回值
        public MyClass(int a, int b)
        {
            this.a = a;
            this.b = b;
        }
    }

    //写一个圆形类,为其添加一个构造函数用来初始化半径
    class Circle
    {
        public float a;
        public Circle()
        {
            a = 2f;
        }

        public Circle(float a)
        {
            this.a = a;
        }
    }


    //调用兄弟构造函数
    class A
    {
        public int a;
        public int b;
        public float c;
        public string v;

        public A(int a)
        {
            this.a = a;
        }

        public A(int a, int b):this(a)
        {
            this.a = b;
        }

        public A(int a, int b, float c):this(a, b)
        {
            this.c = c;
        }

        public A(int a, int b, float c, string v):this(a, b, c)
        {
            this.v = v;
            
        }
    }
}
